﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="房产销冠, 房地产,卡考网络" />
    <meta name="description" content="上海卡考网络有限公司" />
    <title>卡考发货后台</title>
    <link rel="stylesheet" href="css/list.css" type="text/css" />
    <link rel="stylesheet" href="css/global.css" type="text/css" />
    <link href="bootstrap/iCheck-master/skins/minimal/Orange.css" rel="stylesheet" type="text/css" />
    <!--<script src="js/jquery-1.8.3.min.js"></script>-->
    <!--<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />-->
    <script src="http://dn-blqw.qbox.me/jq+bs+art.js" type="text/javascript"></script>
    <!--<script src="js/jquery.easydropdown.min.js"></script>-->
    <script src="bootstrap/iCheck-master/icheck.js"></script>
    <!--<script src="bootstrap/js/bootstrap.min.js"></script>-->
    <!--<script src="js/checkbox.js"></script>-->
    <script src="js/common.js"></script>
    <script src="js/PageIndex.js"></script>
    <script src="http://dn-blqw.qbox.me/kk.js"></script>
    <script src="js/WdatePicker.js"></script>
    <!--<script src="http://static.tops001.com/openSource/iDialog/1.1/jquery.iDialog.js" dialog-theme="default"></script>-->
    <script src="Scripts/jquery.iDialog.js" dialog-theme="default"></script>
</head>
<body style="background: #f1f1f1;">
    <div class="main01">
        <div class="content clearfix">
            <div class="headline02">
                <div class="line_left">发货清单</div>
                <div class="line_right">
                    <ul class="nav_line_right">
                        <li class="con"><a href="#">首页</a></li>
                        <li>/</li>
                        <li class="con"><a href="#">订单管理</a></li>
                        <li>/</li>
                        <li class="con"><a href="#" style="color: #60b12a;">发货清单</a></li>
                    </ul>
                </div>
            </div>
            <div class="bton">
                <div class="bton_left">
                    <select id="F_CityKid" class="selall sel100 fl" style="margin-right:11px;margin-top:5px;margin-left:11px;">
                        <option value="-1">请选择</option>
                    </select>
                    <select id="F_OrderState" class="selall sel100 fl" style="margin-right:11px;margin-top:5px;margin-left:11px;">
                        <option value="0">未发货</option>
                        <option value="1">已发货</option>
                        <option value="2">已确认</option>
                    </select>
                    <select id="F_LogisticsNum" class="selall sel100 fl" style="margin-right:11px;margin-top:5px;margin-left:11px;width:200px;">
                        <option value="0">物流单号</option>
                    </select>

                    <input type="text" id="beginTime" name="beginTime" value="" onclick="WdatePicker()" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" placeholder="  兑换记录审核确认开始时间"
                           style="margin-right:11px;margin-top:5px;margin-left:11px;line-height:28px;border:1px solid #e3e4e6;width:190px;" class="from-control" />
                    <input type="text" id="endTime" name="endTime" value="" onclick="WdatePicker()" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'beginTime\')}' })" placeholder="  兑换记录审核确认结束时间"
                           style="margin-right:11px;margin-top:5px;margin-left:11px;line-height:28px;border:1px solid #e3e4e6;width:190px;" class="from-control" />
                          
                </div>
                <input type="submit" value="搜索" class="sbtn" onclick="f_Search()" style="margin-top:5px;" />
                <div class="bton_right" style="margin-top:5px;">
                    <div class="bton_left_nav">
                        <a href="#" class="btn_deal" style="border:1px solid #e3e4e6;" onclick="f_edits()">批次确认</a>
                        <a href="#" class="btn_craise" id="selboxbt" style="border:1px solid #e3e4e6;">物流修正</a>
                        <a href="#" class="btn_export" onclick="f_ExportExcel()" style="border:1px solid #e3e4e6;">导出</a>
                        <a href="" id="DownLoad" target="_blank" class="btn_export" style="display:none">下载</a>
                    </div>
                    <div class="bton_left_nav pageIn2">
                    </div>
                </div>
            </div>
        </div>
        <div style="min-height: 500px;">
            <table class="table03" style="width: 100%; max-height: 400px; table-layout: fixed; border-bottom: 1px #e6e6e6 solid;">
                <thead>
                    <tr class="info_title">
                        <th style="width:50px;">
                            <input type="checkbox" name="checkbox" id="checkAll" style="display:none" />
                        </th>
                        <th style="width: 40px" class="mid_line">序号</th>
                        <th style="width: 100px;" class="mid_line">城市</th>
                        <th style="width: 140px;" class="mid_line">兑换记录审核确认时间</th>
                        <th style="width: 140px;" class="mid_line">商品名称</th>
                        <th style="width: 100px;" class="mid_line">商品数量</th>
                        <th style="width: 100px;" class="mid_line">金额(元)</th>
                        <th style="width: 100px;" class="mid_line">订单状态</th>
                        <th style="width: 200px;" class="mid_line">物流单号</th>
                        <th style="width: 200px;" class="mid_line">操作</th>
                        <th style="width: 200px"></th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="info_cont" style="display:none">
                        <td>
                            <input type="checkbox" name="subBox" value="{Kid}" productkid="{F_ProductKid}" citykid="{F_CityKid}" logisticsnum="{F_LogisticsNum}" class="subBox" style="width: 50px" />
                        </td>
                        <td>{F_Index}</td>
                        <td>{F_CityName}</td>
                        <td>{F_CreateTime}</td>
                        <td>{F_ProductName} </td>
                        <td>{F_ProductCount}</td>
                        <td>{F_ProductPrice}</td>
                        <td>{F_OrderState}</td>
                        <td>{F_LogisticsNum}</td>
                        <td>{F_Operate}</td>
                    </tr>
                </tbody>
            </table>
            <!--放置分页 begin -->
            <table style="width: 100%; height: auto">
                <tr>
                    <td colspan="15">
                        <div class="pageIn"></div>
                    </td>
                </tr>
            </table>
            <!--放置分页 end -->
        </div>
    </div>
    <div id="selbox" class="clearfix" style="display:none">
        <select id="F_LogisticsNum2" class="selall sel100 fl" style="margin-left:20px;margin-top:10px;width:250px;">
            <option value="-1">物流单号</option>
        </select>
        <input type="text" class="selall sel100 fl" id="logisticsNum" style="margin-left:20px;margin-top:10px;width:250px;" placeholder="修改后的物流单号" maxlength="16" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
    </div>
    <script src="js/list.js"></script>
    <script type="text/javascript">
        $(function () {
            f_GetCityList();
            f_GetLogisticsNumList();
            f_GetData();
        });

        $("#selboxbt").click(function () {
            showWindows("物流单号修正", "selbox", f_editLogisticsNum, 300, 200);
            return false;
        })

        function showWindows(title, id, func, wt, h) {
            $.dialog({
                height: h,
                width: wt,
                fixed: true,
                lock: true,
                title: title,
                content: document.getElementById(id),
                btn: {                      //可以任意定义按钮个数
                    ok: {                     //按钮的key值，下次可用个btn方法从新设置
                        val: '确定',  //按钮显示的文本
                        type: 'orange',
                        click: function () {
                            func();
                        }
                    },
                    canle: {                     //按钮的key值，下次可用个btn方法从新设置
                        val: '取消',
                    }
                },
                init: function () {

                },
            });

        }

        function f_GetCityList() {
            var data = kk.api.get("/Invoice/GetCity", function (data) {
                //$("#F_CityKid").empty();
                $.each(data, function (i, obj) {
                    $("#F_CityKid").append("<option value='" + obj.F_CityKid + "'>" + obj.F_CityName + "</option>");
                });
            });
        }
        function f_GetLogisticsNumList() {
            var data = kk.api.get("/Invoice/GetLogisticsNum", function (data) {
                //$("#F_CityKid").empty();
                $.each(data, function (i, obj) {
                    $("#F_LogisticsNum").append("<option value='" + obj + "'>" + obj + "</option>");
                    $("#F_LogisticsNum2").append("<option value='" + obj + "'>" + obj + "</option>");
                });
            });
        }

        var PageIndex = 1;
        function f_Search() {
            pageIndex = 1;
            f_GetData(pageIndex);
        }

        function f_UrlParStr() {
            var orderState = $("#F_OrderState option:selected").val();
            var cityKid = $("#F_CityKid option:selected").val();
            var logisticsNum = $("#F_LogisticsNum").val();
            var startTime = $("#beginTime").val();
            var endTime = $("#endTime").val();
            return "?cityKid=" + cityKid + "&orderState=" + orderState + "&logisticsNum=" + logisticsNum + "&startTime=" + startTime + "&endTime=" + endTime+"&r="+Math.random();
        }



        //获取记录信息
        function f_GetData(pageIndex) {
            var pageSize = 8;
            var idx = 0;
            var newUrlParStr = f_UrlParStr();
            $kk.api.get("/Invoice/GetList" + newUrlParStr, { pageSize: pageSize, pageIndex: pageIndex }, function (res) {
                kk.fillTable(".table03", res.Items, function (data, name) {
                    if (name == "F_Index") {
                        idx++;
                        var otherCount = pageSize * (pageIndex - 1);
                        if (isNaN(otherCount)) {
                            otherCount = 0;
                        }
                        return idx + otherCount;
                    }
                    if (name == "F_OrderState") {
                        switch (data[name]) {
                            case 0: return "未发货";
                            case 1: return "已发货"
                            case 2: return "已确认"
                        }
                    }
                    if (name == "F_CreateTime") {
                        var date = new Date(data["F_CreateTime"]);
                        return date.toString("yyyy-MM-dd");
                    }
                    if (name === "F_Operate") {
                        if (data["F_OrderState"] == 0) {
                            return "<div class='reset'><a href=\"javascript:;\" onclick=\"f_backout('" + data["F_ProductKid"] + "','" + data["F_CityKid"] + "','" + data["F_CreateTime"] + "')\" class=\"btn_revise\">撤销</a></div>";
                        }
                        if (data["F_OrderState"] == 1) {
                            return "<div class='reset'><a href=\"javascript:;\" onclick=\"f_edit('" + data["F_ProductKid"] + "','" + data["F_LogisticsNum"] + "','" + data["F_CityKid"] + "','" + data["F_CityName"] + "','" + data["F_ProductName"] + "')\" class=\"btn_revise\">确认收货</a></div>";
                        }
                        //return "<a href=\"javascript:;\" onclick=\"f_Detail(" + data["F_ProductKid"] + "," + data["F_OrderState"] + ")\" class=\"btn_revise\">详情</a>";
                    }
                    if (name == "IsStatus_check") {
                        return data["F_IsStatus"];
                    }
                });
                $("#RecordCount").html(res.Count);
                makePageBar(f_GetData, res.Count, pageIndex, pageSize);
                PageIndex = pageIndex;
                $(':checkbox').not(".notneeddraw").iCheck({
                    checkboxClass: 'icheckbox_minimal-orange',
                    radioClass: 'iradio_minimal-orange',
                    increaseArea: '20%' // optional
                });
                $('#checkAll').css('display', 'block');
                $('.info_title .iCheck-helper').on('click', function () {
                    if ($(".icheckbox_minimal-orange:first").hasClass("checked")) {
                        $('.subBox').iCheck('check');
                    } else {
                        $('.subBox').iCheck('uncheck');
                    }
                });
                $('.pageIn').on('click', function () {
                    //console.log(111);
                    $('.checked:first').iCheck('uncheck');
                })
            });
        }


        //批量编辑
        function f_edits() {
            var logisticsNum = $('#F_LogisticsNum').val();
            var cityKid = $("#F_CityKid option:selected").val();
            var cityName = $("#F_CityKid option:selected").text();
            if (cityKid < 0) {
                $kk.popup("必须选择一个城市", "danger", 1000);
                return;
            }
            if (logisticsNum == 0) {
                $kk.popup("必须指定一个物流单号", "danger", 1000);
                return;
            }
            kk.confirm(
            '确认已收到货物吗？<hr/>城市：' + cityName + '<br/>物流单号：' + logisticsNum
            , "批量填写物流单号", "", "", function () {
                kk.api.get("/Invoice/Confirms", { logisticsNum: logisticsNum, cityKid: cityKid }, function (res) {
                    if (res) {
                        $kk.popup("操作成功", "success", 1000);
                        f_GetData(PageIndex);
                    } else {
                        $kk.popup("操作失败", "danger", 1000);
                    }
                });
            }, null);
        }


        //编辑
        function f_edit(productKid, logisticsNum, cityKid, cityName, productName) {
            if (logisticsNum == 'undefined') {
                logisticsNum = '';
            }
            kk.confirm(
                '确认已收到货物吗？<hr/>城市：' + cityName + '<br/>物流单号：' + logisticsNum + '<br/>商品：' + productName
                , "提示", "", "", function () {
                    kk.api.get("/Invoice/Confirms", { productKid: productKid, cityKid: cityKid, logisticsNum: logisticsNum }, function (res) {
                        if (res) {
                            $kk.popup("操作成功", "success", 1000);
                            f_GetData(PageIndex);
                        } else {
                            $kk.popup("操作失败", "danger", 1000);
                        }
                    });
                }, null);
        }

        function f_backout(productKid,cityKid,createTime) {
            kk.confirm(
                '确认要撤销货物吗？<br/>'+
                '<input type="text" class="selall sel100 fl" id="num" style="margin-right:11px;margin-top:5px;width:250px;" placeholder="撤销数量" max="16" onkeyup="this.value=this.value.replace(/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(/\\D/g,\'\')" /><br/>' 
                , "提示", "", "", function () {
                    var num = $('#num').val();
                    if (num==''||num==0) {
                        $kk.popup("请填写撤销数量", "danger", 1000);
                        return;
                    }
                    kk.api.get("/Invoice/Backout", { productKid: productKid, cityKid: cityKid, createTime: createTime,num:num}, function (res) {
                        if (res) {
                            $kk.popup("操作成功", "success", 1000);
                            f_GetData(PageIndex);
                        } else {
                            $kk.popup("操作失败", "danger", 1000);
                        }
                    });
                }, null);
        }

        function f_Detail(productKid, orderstate) {
            var cityKid = $("#F_CityKid option:selected").val();
            location.href = "invoiceDetail.html?cityKid=" + cityKid + "&productKid=" + productKid + "&orderState=" + orderstate;
        }

        function f_ExportExcel() {
            var newUrlParStr = f_UrlParStr();
            var cityKid = $("#F_CityKid option:selected").val();
            if (cityKid < 0) {
                $kk.popup("请选择一个城市", "danger", 1000);
                return;
            }
            $kk.api.get("/Invoice/Export" + newUrlParStr, function (res) {
                //window.location.href = window.location.host + res;
                //window.open(window.location.host + res)
                //$("#DownLoad").attr("href", window.location.host + res)
                $("#DownLoad").attr("href", res)
                $("#DownLoad").show();
            });
        }

        function f_editLogisticsNum()
        {
            var oldnum = $('#F_LogisticsNum2').val();
            var newnum = $('#logisticsNum').val();
            if (oldnum==-1) {
                $kk.popup("必须指定一个物流单号", "danger", 1000);
                return;
            }
            if (newnum=='') {
                $kk.popup("填写的新物流编号不能为空", "danger", 1000);
                return;
            }
            kk.api.get("/Invoice/EditLogisticsNum", { oldnum: oldnum, newnum: newnum }, function (res) {
                if (res) {
                    //$kk.popup("操作成功", "success", 1000);
                    document.location.reload();
                } else {
                    $kk.popup("操作失败", "danger", 1000);
                }
            });
        }
    </script>
</body>
</html>
